using UnityEngine;

namespace Coffee.UIExtensions
{
    // [Assembly-CSharp.dll].Coffee.UIExtensions.UIEffect
    public class UIEffect : UIEffectBase
    {
        
        #region Coffee.UIExtensions.UIEffect.BlurEx
        // [Assembly-CSharp.dll].Coffee.UIExtensions.UIEffect.BlurEx
        public enum BlurEx
        {
            // Fields
            None = 0
            ,Ex = 1
            
        
        }
        
        #endregion
        
        // Fields
        public const string shaderName = "UI/Hidden/UI-Effect";
        private static readonly Coffee.UIExtensions.ParameterTexture _ptex;
        private float m_EffectFactor;
        private float m_ColorFactor;
        private float m_BlurFactor;
        private Coffee.UIExtensions.EffectMode m_EffectMode;
        private Coffee.UIExtensions.ColorMode m_ColorMode;
        private Coffee.UIExtensions.BlurMode m_BlurMode;
        private bool m_AdvancedBlur;
        private float m_ShadowBlur;
        private Coffee.UIExtensions.ShadowStyle m_ShadowStyle;
        private UnityEngine.Color m_ShadowColor;
        private UnityEngine.Vector2 m_EffectDistance;
        private bool m_UseGraphicAlpha;
        private UnityEngine.Color m_EffectColor;
        private System.Collections.Generic.List<Coffee.UIExtensions.UIShadow.AdditionalShadow> m_AdditionalShadows;
        
        // Properties
        public float toneLevel { get; set; }
        public float effectFactor { get; set; }
        public float colorFactor { get; set; }
        public float blur { get; set; }
        public float blurFactor { get; set; }
        public Coffee.UIExtensions.EffectMode toneMode { get; }
        public Coffee.UIExtensions.EffectMode effectMode { get; }
        public Coffee.UIExtensions.ColorMode colorMode { get; }
        public Coffee.UIExtensions.BlurMode blurMode { get; }
        public UnityEngine.Color effectColor { get; set; }
        public override Coffee.UIExtensions.ParameterTexture ptex { get; }
        
        // Methods
        public float get_toneLevel()
        {
            return (float)this.m_EffectFactor;
        }
        public void set_toneLevel(float value)
        {
            this.m_EffectFactor = (value >= 0) ? value : 0f;
            goto typeof(Coffee.UIExtensions.UIEffect).__il2cppRuntimeField_2D8;
        }
        public float get_effectFactor()
        {
            return (float)this.m_EffectFactor;
        }
        public void set_effectFactor(float value)
        {
            this.m_EffectFactor = (value >= 0) ? value : 0f;
            goto typeof(Coffee.UIExtensions.UIEffect).__il2cppRuntimeField_2D8;
        }
        public float get_colorFactor()
        {
            return (float)this.m_ColorFactor;
        }
        public void set_colorFactor(float value)
        {
            this.m_ColorFactor = (value >= 0) ? value : 0f;
            goto typeof(Coffee.UIExtensions.UIEffect).__il2cppRuntimeField_2D8;
        }
        public float get_blur()
        {
            return (float)this.m_BlurFactor;
        }
        public void set_blur(float value)
        {
            this.m_BlurFactor = (value >= 0) ? value : 0f;
            goto typeof(Coffee.UIExtensions.UIEffect).__il2cppRuntimeField_2D8;
        }
        public float get_blurFactor()
        {
            return (float)this.m_BlurFactor;
        }
        public void set_blurFactor(float value)
        {
            this.m_BlurFactor = (value >= 0) ? value : 0f;
            goto typeof(Coffee.UIExtensions.UIEffect).__il2cppRuntimeField_2D8;
        }
        public Coffee.UIExtensions.EffectMode get_toneMode()
        {
            return (Coffee.UIExtensions.EffectMode)this.m_EffectMode;
        }
        public Coffee.UIExtensions.EffectMode get_effectMode()
        {
            return (Coffee.UIExtensions.EffectMode)this.m_EffectMode;
        }
        public Coffee.UIExtensions.ColorMode get_colorMode()
        {
            return (Coffee.UIExtensions.ColorMode)this.m_ColorMode;
        }
        public Coffee.UIExtensions.BlurMode get_blurMode()
        {
            return (Coffee.UIExtensions.BlurMode)this.m_BlurMode;
        }
        public UnityEngine.Color get_effectColor()
        {
            UnityEngine.UI.Graphic val_1 = this.graphic;
            goto typeof(UnityEngine.UI.Graphic).__il2cppRuntimeField_298;
        }
        public void set_effectColor(UnityEngine.Color value)
        {
            UnityEngine.UI.Graphic val_1 = this.graphic;
            goto typeof(Coffee.UIExtensions.UIEffect).__il2cppRuntimeField_2D8;
        }
        public override Coffee.UIExtensions.ParameterTexture get_ptex()
        {
            if(mem[536895015] != 0)
            {
                    return (Coffee.UIExtensions.ParameterTexture)mem[536894975];
            }
            
            536894791 = 536894791;
            return (Coffee.UIExtensions.ParameterTexture)mem[536894975];
        }
        public override void ModifyMesh(UnityEngine.UI.VertexHelper vh)
        {
            float val_14;
            float val_15;
            float val_21;
            float val_28;
            float val_29;
            float val_30;
            float val_31;
            float val_32;
            float val_33;
            UnityEngine.UI.VertexHelper val_42;
            var val_43;
            int val_44;
            var val_45;
            var val_47;
            float val_48;
            float val_50;
            var val_52;
            var val_53;
            float val_54;
            float val_55;
            var val_56;
            float val_57;
            float val_58;
            float val_59;
            float val_60;
            var val_61;
            var val_63;
            val_42 = vh;
            if(this.isActiveAndEnabled == false)
            {
                    return;
            }
            
            if((this.m_BlurMode == 0) || (this.m_AdvancedBlur == false))
            {
                goto label_4;
            }
            
            val_42.GetUIVertexStream(stream:  mem[536894979] + 8);
            val_42.Clear();
            if(this.graphic == null)
            {
                goto label_8;
            }
            
            var val_4 = (((UnityEngine.UI.Graphic.__il2cppRuntimeField_typeHierarchy + (mem[536894131]) << 3) + -8) == 536893831) ? 6 : (mem[536894979] + 8 + 24);
            goto label_10;
            label_4:
            int val_5 = val_42.currentVertCount;
            if(val_5 < 1)
            {
                    return;
            }
            
            do
            {
                val_42.PopulateUIVertex(vertex:  new UnityEngine.UIVertex() {position = new UnityEngine.Vector3() {x = 0f, y = 0f, z = 0f}, normal = new UnityEngine.Vector3() {x = 0f, y = 0f, z = 0f}, tangent = new UnityEngine.Vector4() {x = 0f, y = 0f, z = 0f, w = 0f}, color = new UnityEngine.Color32(), uv0 = new UnityEngine.Vector4() {x = 0f, y = 0f, z = 0f, w = 0f}, uv1 = new UnityEngine.Vector4() {x = 0f, y = 0f, z = 0f, w = 0f}, uv2 = new UnityEngine.Vector4() {x = 0f, y = 0f, z = 0f, w = 0f}, uv3 = new UnityEngine.Vector4() {x = 0f, y = 0f, z = 0f, w = 0f}}, i:  0);
                float val_42 = 0f;
                float val_43 = 0f;
                val_42 = val_42 + 0.5f;
                val_43 = val_43 + 0.5f;
                val_42 = val_42 * 0.5f;
                val_43 = val_43 * 0.5f;
                float val_6 = Packer.ToFloat(x:  val_42, y:  val_43);
                val_42.SetUIVertex(vertex:  new UnityEngine.UIVertex() {position = new UnityEngine.Vector3(), normal = new UnityEngine.Vector3(), tangent = new UnityEngine.Vector4(), color = new UnityEngine.Color32(), uv0 = new UnityEngine.Vector4(), uv1 = new UnityEngine.Vector4(), uv2 = new UnityEngine.Vector4(), uv3 = new UnityEngine.Vector4()}, i:  0);
                val_43 = 0 + 1;
            }
            while(val_5 != val_43);
            
            return;
            label_8:
            label_10:
            float val_44 = 6f;
            val_44 = 0;
            val_44 = (float)this.m_BlurMode * val_44;
            val_44 = val_44 + val_44;
            label_40:
            val_45 = 536894795;
            if(mem[536895019] == 0)
            {
                    val_45 = 536894795;
            }
            
            if(val_44 >= (mem[536894979] + 8 + 24))
            {
                goto label_16;
            }
            
            Coffee.UIExtensions.UIEffect.GetBounds(verts:  mem[536894979] + 8, start:  0, count:  mem[536894979] + 8 + 24, posBounds:  new UnityEngine.Rect() {m_XMin = 0f, m_YMin = (float)this.m_BlurMode, m_Width = 0f}, uvBounds:  new UnityEngine.Rect(), global:  true);
            if((mem[536894979] + 8 + 24) < 1)
            {
                goto label_18;
            }
            
            var val_45 = 0;
            var val_50 = val_44;
            label_39:
            val_47 = 536894795;
            if(mem[536895019] == 0)
            {
                    val_47 = 536894795;
            }
            
            val_45 = val_45 + val_44;
            val_44 = val_45 + 1;
            Unknown val_13 = mem[536894979] + 8.Item[val_44];
            int val_16 = val_45 + 4;
            Unknown val_17 = mem[536894979] + 8.Item[val_16];
            val_48 = val_14;
            if(((mem[536894979] + 8 + 24) == 6) || ((0.Contains(point:  new UnityEngine.Vector3() {x = val_14, y = val_14, z = val_15})) == false))
            {
                goto label_24;
            }
            
            val_50 = val_15;
            if((0.Contains(point:  new UnityEngine.Vector3() {x = val_48, y = val_48, z = val_50})) == false)
            {
                goto label_24;
            }
            
            val_52 = 0;
            goto label_25;
            label_24:
            val_53 = 536894795;
            if(mem[536895019] == 0)
            {
                    val_53 = 536894795;
            }
            
            Unknown val_20 = mem[536894979] + 8.Item[val_44];
            Unknown val_22 = mem[536894979] + 8.Item[val_16];
            float val_46 = val_21;
            float val_23 = val_15 ?? V12.2S;
            float val_24 = val_15 + V12.2S;
            val_23 = val_44 / val_23;
            double val_47 = 1;
            val_46 = val_21 + val_46;
            val_24 = val_24 * 0.5f;
            val_47 = val_23 + val_47;
            val_46 = val_46 * 0.5f;
            val_23 = val_24 * val_47;
            val_50 = val_24 - val_23;
            val_48 = val_46 - (val_47 * val_46);
            val_52 = 1;
            label_25:
            var val_49 = 0;
            val_54 = val_50;
            val_55 = val_48;
            label_38:
            val_56 = 536894795;
            if(mem[536895019] == 0)
            {
                    val_56 = 536894795;
            }
            
            int val_26 = val_50 + val_49;
            Unknown val_27 = mem[536894979] + 8.Item[val_26];
            val_57 = val_28;
            val_58 = val_14;
            val_59 = val_33;
            val_60 = val_21;
            if(1 == 0)
            {
                goto label_35;
            }
            
            float val_34 = 0.xMin;
            if(val_58 >= 0)
            {
                    if(0.xMax >= 0)
            {
                goto label_33;
            }
            
            }
            
            val_50 = val_54;
            val_58 = val_50 + (val_47 * val_58);
            val_55 = val_55;
            val_54 = val_47 * val_60;
            val_60 = val_55 + val_54;
            label_33:
            float val_37 = 0.yMin;
            if(val_57 >= 0)
            {
                    if(0.yMax >= 0)
            {
                goto label_35;
            }
            
            }
            
            float val_48 = val_47;
            val_57 = val_50 + (val_48 * val_57);
            val_48 = val_48 * val_59;
            val_59 = val_48 + val_48;
            label_35:
            float val_40 = val_60 + 0.5f;
            val_48 = val_59 + 0.5f;
            val_40 = val_40 * 0.5f;
            val_48 = val_48 * 0.5f;
            val_61 = 536894795;
            if(mem[536895019] == 0)
            {
                    val_61 = 536894795;
            }
            
            val_28 = val_57;
            val_14 = val_58;
            val_15 = val_15;
            val_29 = val_29;
            val_30 = val_30;
            val_33 = this.GetNormalizedIndex(target:  this);
            val_21 = Packer.ToFloat(x:  val_40, y:  val_48);
            val_31 = val_31;
            val_32 = val_32;
            mem[536894979] + 8.set_Item(index:  val_26, value:  new UnityEngine.UIVertex() {position = new UnityEngine.Vector3() {x = val_14, y = val_28, z = val_15}, normal = new UnityEngine.Vector3() {x = val_29, y = val_29, z = val_29}, tangent = new UnityEngine.Vector4() {x = val_29, y = val_30, z = val_30, w = val_30}, color = new UnityEngine.Color32() {r = val_30, g = val_30, b = val_30, a = val_30}, uv0 = new UnityEngine.Vector4() {x = val_21, y = val_33, z = 0f, w = 0f}, uv1 = new UnityEngine.Vector4() {x = Packer.ToFloat(x:  0.xMin, y:  0.yMin), y = Packer.ToFloat(x:  0.xMax, y:  0.yMax), z = 0f, w = 0f}, uv2 = new UnityEngine.Vector4() {x = val_31, y = val_31, z = val_31, w = val_31}, uv3 = new UnityEngine.Vector4() {x = val_32, y = val_32, z = val_32, w = val_32}});
            val_49 = val_49 + 1;
            if(val_49 != 6)
            {
                goto label_38;
            }
            
            val_63 = val_44;
            val_50 = val_50 + 6;
            if(6 < (mem[536894979] + 8 + 24))
            {
                goto label_39;
            }
            
            label_18:
            val_63 = val_63 + (mem[536894979] + 8 + 24);
            goto label_40;
            label_16:
            val_42.AddUIVertexTriangleStream(verts:  mem[536894979] + 8);
            var val_51 = mem[536894979] + 8 + 28;
            val_51 = val_51 + 1;
            mem2[0] = 0;
            mem2[0] = val_51;
        }
        protected override void SetDirty()
        {
            this.RegisterMaterial(mat:  typeof(Coffee.UIExtensions.UIEffect).__il2cppRuntimeField_2C0);
            float val_2 = (this.m_EffectFactor >= 0) ? (S2 * 255f) : 0f;
            this.SetData(target:  this, channelId:  0, value:  (val_2 < 0) ? ((int)val_2) : ((int)val_2));
            float val_5 = (this.m_ColorFactor >= 0) ? (S2 * 255f) : 0f;
            this.SetData(target:  this, channelId:  1, value:  (val_5 < 0) ? ((int)val_5) : ((int)val_5));
            float val_8 = (this.m_BlurFactor >= 0) ? (S3 * 255f) : 0f;
            this.SetData(target:  this, channelId:  2, value:  (val_8 < 0) ? ((int)val_8) : ((int)val_8));
        }
        private static void GetBounds(System.Collections.Generic.List<UnityEngine.UIVertex> verts, int start, int count, UnityEngine.Rect posBounds, UnityEngine.Rect uvBounds, bool global)
        {
            float val_3;
            float val_4;
            float val_5;
            float val_6;
            int val_20;
            float val_21;
            float val_22;
            float val_23;
            float val_24;
            float val_25;
            float val_26;
            float val_27;
            float val_28;
            int val_20 = count;
            val_20 = start;
            if((val_20 + val_20) > val_20)
            {
                    val_21 = -1.175494E-38f;
                val_22 = 1.175494E-38f;
                val_23 = val_22;
                val_24 = val_21;
                val_25 = val_22;
                val_26 = val_22;
                val_27 = val_21;
                val_28 = val_21;
                do
            {
                Unknown val_2 = verts.Item[val_20];
                if((val_27 >= val_3) && (val_28 >= val_4))
            {
                    val_28 = val_4;
                val_27 = val_3;
            }
            else
            {
                    var val_7 = (val_25 > val_3) ? 1 : 0;
                val_7 = val_7 | ((val_26 > val_4) ? 1 : 0);
                var val_9 = (val_7 != 0) ? (val_26) : (val_4);
                var val_10 = (val_7 != 0) ? (val_25) : (val_3);
            }
            
                if((val_21 >= val_5) && (val_24 >= val_6))
            {
                    val_24 = val_6;
                val_21 = val_5;
            }
            else
            {
                    var val_11 = (val_22 > val_5) ? 1 : 0;
                val_11 = val_11 | ((val_23 > val_6) ? 1 : 0);
                var val_13 = (val_11 != 0) ? (val_23) : (val_6);
                var val_14 = (val_11 != 0) ? (val_22) : (val_5);
            }
            
                val_20 = val_20 - 1;
                val_20 = val_20 + 1;
            }
            while(val_11 != 0);
            
            }
            else
            {
                    val_26 = 1.175494E-38f;
                val_28 = -1.175494E-38f;
                val_27 = val_28;
                val_25 = val_26;
                val_24 = val_28;
                val_21 = val_28;
                val_23 = val_26;
                val_22 = val_26;
            }
            
            float val_21 = 0.001f;
            float val_22 = -0.002f;
            float val_15 = val_25 - val_27;
            val_21 = val_28 + val_21;
            val_15 = val_15 + val_22;
            val_22 = (val_26 - val_28) + val_22;
            global.Set(x:  val_27 + val_21, y:  val_21, width:  val_15, height:  val_22);
            X4.Set(x:  val_21, y:  val_24, width:  val_22 - val_21, height:  val_23 - val_24);
        }
        public UIEffect()
        {
            this.m_EffectFactor = 1;
            this.m_ShadowColor = ;
            this.m_BlurFactor = 1f;
            this.m_ShadowBlur = 1f;
            this.m_EffectDistance = -0.00781250184809323;
            this.m_UseGraphicAlpha = true;
            this.m_EffectColor = 1;
            System.Collections.Generic.List<System.Object> val_1 = 536903863;
            val_1 = new System.Collections.Generic.List<System.Object>();
            this.m_AdditionalShadows = val_1;
            this = new UnityEngine.UI.BaseMeshEffect();
        }
        private static UIEffect()
        {
            Coffee.UIExtensions.ParameterTexture val_1 = 536890543;
            val_1 = new Coffee.UIExtensions.ParameterTexture(channels:  4, instanceLimit:  0, propertyName:  -1610600767);
            mem2[0] = val_1;
            throw new NullReferenceException();
        }
    
    }

}
